home *** CD-ROM | disk | FTP | other *** search
/ Champak 132 (Alt) / Vol 132.iso / games / sweettim.swf / scripts / frame_8 / PlaceObject2_212_191 / CLIPACTIONRECORD onClipEvent(load).as < prev   
Encoding:
Text File  |  2011-06-09  |  2.7 KB  |  111 lines

  1. onClipEvent(load){
  2.    function init()
  3.    {
  4.       i = 1;
  5.       while(i <= 9)
  6.       {
  7.          eval("_root.icon_" + i).sweet_num.gotoAndStop(i);
  8.          if(i == 1)
  9.          {
  10.             rndSweetType = 1 + Math.floor(Math.random() * 9);
  11.             sweetRack[i - 1][0] = rndSweetType;
  12.             eval("_root.icon_" + i).sweet_icon.gotoAndStop(rndSweetType);
  13.             eval("_root.area_" + i).gotoAndStop(rndSweetType);
  14.          }
  15.          else
  16.          {
  17.             sweetFound = false;
  18.             rndSweetType = 1 + Math.floor(Math.random() * 9);
  19.             x = 1;
  20.             while(x <= 9)
  21.             {
  22.                if(sweetRack[x - 1][0] == rndSweetType)
  23.                {
  24.                   sweetFound = true;
  25.                }
  26.                x++;
  27.             }
  28.             while(sweetFound)
  29.             {
  30.                sweetFound = false;
  31.                rndSweetType = 1 + Math.floor(Math.random() * 9);
  32.                x = 1;
  33.                while(x <= 9)
  34.                {
  35.                   if(sweetRack[x - 1][0] == rndSweetType)
  36.                   {
  37.                      sweetFound = true;
  38.                   }
  39.                   x++;
  40.                }
  41.             }
  42.             sweetRack[i - 1][0] = rndSweetType;
  43.             eval("_root.icon_" + i).sweet_icon.gotoAndStop(rndSweetType);
  44.             eval("_root.area_" + i).gotoAndStop(rndSweetType);
  45.          }
  46.          i++;
  47.       }
  48.       trace(sweetRack);
  49.    }
  50.    function getSweetbagValue()
  51.    {
  52.       emptyTotal = 0;
  53.       i = 0;
  54.       while(i <= 8)
  55.       {
  56.          emptyTotal += sweetRack[i][1];
  57.          i++;
  58.       }
  59.       if(emptyTotal != 900)
  60.       {
  61.          percentFull = Math.floor((900 - emptyTotal) / 900 * 100);
  62.       }
  63.       else
  64.       {
  65.          percentFull = 0;
  66.       }
  67.       rackValue = 0;
  68.       if(percentFull > 0 && percentFull < 25)
  69.       {
  70.          rackValue = 125;
  71.       }
  72.       else if(percentFull >= 25 && percentFull < 50)
  73.       {
  74.          rackValue = 250;
  75.       }
  76.       else if(percentFull >= 50 && percentFull < 80)
  77.       {
  78.          rackValue = 375;
  79.       }
  80.       else if(percentFull >= 80)
  81.       {
  82.          rackValue = 500;
  83.       }
  84.       return rackValue;
  85.    }
  86.    function rackStatus()
  87.    {
  88.       emptyTotal = 0;
  89.       i = 0;
  90.       while(i <= 8)
  91.       {
  92.          emptyTotal += sweetRack[i][1];
  93.          i++;
  94.       }
  95.       if(emptyTotal != 900)
  96.       {
  97.          rack_status = "full";
  98.       }
  99.       else
  100.       {
  101.          rack_status = "empty";
  102.       }
  103.       return rack_status;
  104.    }
  105.    fps = 10;
  106.    timer = fps * 2;
  107.    numSweets = 9;
  108.    sweetRack = new Array([0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]);
  109.    init();
  110. }
  111.